<?php


class WSB_Controller_Helper_Translate extends Zend_Controller_Action_Helper_Abstract
{
	/**
	 * Zends Translate-Objekt
	 *
	 * @var Zend_Translate
	 */
	private $_translate;

	public function __construct()
	{
		$this->_translate = Zend_Registry::get('Zend_Translate');
		$moduleName = $this->getRequest()->getModuleName();
		$controllerName = $this->getRequest()->getControllerName();
		$locale = Zend_Registry::get('Zend_Locale');
		$translation = sprintf(
			'%s/../etc/%s.%s.csv',
			Zend_Controller_Front::getInstance()->getControllerDirectory($moduleName),
			strtolower($controllerName),
			$locale
		);
		if(is_file($translation)) {
			$this->_translate->addTranslation($translation, $locale);
		}
	}

	/**
	 * @param string $str
	 * @return string
	 */
	public function direct($str)
	{
		return $this->_translate->translate($str);
	}

}